package generic.dao.impl;

import generic.dao.GenericDao;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.io.Serializable;
import java.util.List;


public class GenericDaoImpl<T,PK extends Serializable> extends HibernateDaoSupport implements GenericDao<T, PK> {

    @Override
    public T findById(Class<T> clazz,PK id) {
        return (T)this.getHibernateTemplate().get(clazz, id);
    }

    @Override
    public void save(T entity) {
        this.getHibernateTemplate().save(entity);
    }

    @Override
    public void update(T entity) {
        this.getHibernateTemplate().update(entity);
    }

    @Override
    public void delete(T entity) {
        this.getHibernateTemplate().delete(entity);
    }

    @Override
    public List<T> findObj(String queryString, Object[] params) {
        return (List<T>)this.getHibernateTemplate().find(queryString,params);
    }

}
